Repository navigation
Follow only same-origin and Hugging Face CDN redirects for MiMo prompt fixtures - #1924
Merged
Merged
Conversation
…t fixtures prepare-mimo-prompt-fixtures.py let urllib follow any redirect and refused only a final plain-HTTP URL, so a download could request another host, or a plain-HTTP URL, before the check ran. It now opens each file through OriginRedirect: a redirect is followed only when the target has the scheme, host and port of the URL that answered with it and carries no credentials, or, from https://huggingface.co only, when the target is an HTTPS Hugging Face CDN host on port 443 (hf.co or a name that ends in .hf.co). The Hub answers tokenizer.json at the pinned revision with a 302 to us.aws.cdn.hf.co; the other three files take a same-origin 307. Any other redirect raises ValueError before its target is requested and is not retried. The SHA-256 pins still protect the bytes. The rule lives in scripts/fixture_redirects.py. The image fixture script's curl loop and prepare-prompt-fixtures.py's SameOriginRedirect now use it instead of their own origin comparisons; the latter still refuses a target with a query or fragment. The CI component paths, the release-cache workflow paths and the docs-impact rules name the new module. The self-test drives the script's own redirect handler through urllib with a recording fake origin: same-origin and *.hf.co redirects are followed; plain-HTTP, other-host, other-port, credentialed and suffix-trick targets (hf.co.evil.example, evilhf.co) fail at once, unrequested and unretried; a CDN host cannot redirect onward. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-asset origins the same way The refactor reviewer's cleanups: redirect_allowed returns early when the CDN allowance is off or the source is not the Hub, and the constant is named HUGGING_FACE_HUB_ORIGIN; the test says why it copies the handler. prepare-prompt-fixtures.py compared the final response with (scheme, netloc) while each hop now compares (scheme, host, port with its default). It now uses fixture_redirects.origin for both, so a same-origin hop with an explicit :443 is not refused afterwards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/prepare-mimo-prompt-fixtures.pynow follows a redirect only in two cases (David's ruling, 2026-11-09):https://huggingface.coredirects over HTTPS to a Hugging Face CDN host on port 443:hf.co, or a name that ends in.hf.co.A target with credentials is always refused. Any other redirect (another host, another port, plain HTTP) raises
ValueErrorbefore its target is requested, and it is not retried. The SHA-256 pins still protect the bytes.Before this PR, the script let
urlopenfollow any redirect and then refused only a final plain-HTTP URL. So it could request another host, or a plain-HTTP URL, before the check ran.Why the CDN allowance, and how narrow it is
On 2026-11-08 I checked what the Hub answers for the four pinned files at revision
5711b268…:tokenizer.jsonhttps://us.aws.cdn.hf.co/xet-bridge-us/…?Expires=…&Signature=…, which answers 200 with the pinned SHA-256ff15eb92…config.json,tokenizer_config.json,chat_template.jinja/api/resolve-cache/…onhuggingface.co(same origin)A strict same-origin rule would therefore refuse
tokenizer.jsonon every cache miss. Hugging Face serves Xet and LFS files from names underhf.co, for exampleus.aws.cdn.hf.co,cas-bridge.xethub.hf.coandcdn-lfs*.hf.co. The allowance is therefore:https://huggingface.co:443;https, port 443, with no credentials;hf.coor a name that ends in.hf.co. The check is an exact name or a dot-separated suffix, sohf.co.evil.exampleandevilhf.codo not match;*.hf.cohost.The legacy
cdn-lfs.huggingface.cois not allowed. These files do not use it.Shared rule, no third copy
The rule is in the new
scripts/fixture_redirects.py(origin,redirect_allowed, and the urllib handlerOriginRedirect). All three downloaders now use it:prepare-mimo-prompt-fixtures.py: opens throughOriginRedirect(hugging_face_cdn=True).prepare-mimo-image-http-fixtures.py(Keep MiMo image fixture redirects on the requested origin #1865): its curl loop callsredirect_allowedinstead of its ownorigin()copy. It is still same-origin only.prepare-prompt-fixtures.py:SameOriginRedirectnow extendsOriginRedirectand still refuses a target with a query or fragment (https_url). The final-response check uses the sameorigin(). Before, it compared(scheme, netloc), so a same-origin hop with an explicit:443would have been followed and then refused.The CI component paths (
scripts/ci-component-paths.pyand its test), the release-cache workflow paths and the docs-impact rules name the new module.Before and after
No Mermaid, at the requester's instruction. Text diagrams:
Before:
After:
Validation
scripts/test-prepare-mimo-prompt-fixtures.py) drive the script's own redirect handler through urllib, with a fake origin that records every request::443), andhuggingface.cotous.aws.cdn.hf.co,cas-bridge.xethub.hf.co,cdn-lfs-us-1.hf.coandhf.co.http://us.aws.cdn.hf.co,http://huggingface.co,evil.example,huggingface.co:8443,us.aws.cdn.hf.co:8443, a credentialed CDN URL,hf.co.evil.example,evilhf.coandhuggingface.co.hf.co.evil.example.evil.exampleor tocas-bridge.xethub.hf.co) is refused. The allowance does not apply from a source other thanhttps://huggingface.co:443.f42e459fis green. That covers Check the CI plans, both Provider Unit Tests shards, the Provider Tests gate and every cluster job. SDK 27 release preparation run 42558488912 is also green. In the offline downloader step, the self-tests passed: prompt-asset 18 tests, MiMo prompt 15 tests (3 of them new) and MiMo image 12 tests. The two Vercel deployments (d-inferenceandd-inference-console-ui-dev) failed, as they do on every PR.Components touched
Protocol / interface changes
Documentation impact
docs/developer/test.md(Public Fixtures And Private Qualification) anddocs/developer/mimo-prompt-fixtures.md.Changelog
changelog.d/mimo-prompt-fixture-redirects.md.Refactor Pass
A separate refactor reviewer read the diff and checked it against the urllib source. It found no correctness bug. It confirmed:
ValueErrorreaches the caller unwrapped, so it is not retried.It made two cleanups, in
f42e459f:redirect_allowedreturns early outside the Hub hop (with the constant renamed toHUGGING_FACE_HUB_ORIGIN), and the test comments on why it copies the handler. It also pointed out that the final-response check inprepare-prompt-fixtures.pycompared netlocs. That check now uses the sharedorigin(), in the same commit.🤖 Generated with Claude Code